package com.huawei.appgallery.forum.cards.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewStub;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import androidx.appcompat.widget.ActivityChooserView.ActivityChooserViewAdapter;
import com.huawei.appgallery.forum.base.card.bean.Post;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.bean.ForumFeedPostCardBean;
import com.huawei.appgallery.forum.cards.widget.PostSectionContentView;
import com.huawei.appgallery.forum.cards.widget.PostUserContentView;
import com.huawei.appgallery.forum.section.api.ISectionDetailActivityProtocol;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import o.azb;
import o.bsp;
import o.bsx;
import o.bsy;
import o.bsy.c;
import o.bsy.e;
import o.bth;
import o.cgy;
import o.cgz;
import o.cil;
import o.cim.a;
import o.eqx;
import o.fho;
import o.fiu;
import o.fjb;

public class ForumFeedPostCard extends ForumPostCard implements bth {
    private PostSectionContentView ˋˋ;
    private ImageView ˋᐝ;
    private ImageView ˌ;
    private ImageView ˍ;
    private ForumFeedPostCardBean ˎˎ;
    private ViewStub ॱᐝ;

    public ForumFeedPostCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        cgz ˏ = super.ˏ(view);
        this.ˌ = (ImageView) view.findViewById(c.ꞌ);
        this.ˋᐝ = (ImageView) view.findViewById(c.ˏॱ);
        this.ˍ = (ImageView) view.findViewById(c.ˋॱ);
        return ˏ;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof ForumFeedPostCardBean) {
            this.ˎˎ = (ForumFeedPostCardBean) cardBean;
        }
        super.ˏ(cardBean);
    }

    protected void ˎ(View view) {
        this.ʻॱ = (ViewStub) view.findViewById(c.ˑॱ);
        this.ॱᐝ = (ViewStub) view.findViewById(c.ॱˋ);
    }

    protected void ˎ() {
        if (this.ˎˎ == null) {
            this.ʻॱ.setVisibility(8);
            this.ॱᐝ.setVisibility(8);
        } else if (this.ˎˎ.ˎ() == 0) {
            if (this.ᐝॱ == null) {
                this.ᐝॱ = (PostUserContentView) this.ʻॱ.inflate();
            }
            this.ᐝॱ.setUserContentClickLisenter(this);
            this.ᐝॱ.setData(this.ˎˎ.ᐝ(), this.ˎˎ.ˋॱ());
            this.ʻॱ.setVisibility(0);
            this.ॱᐝ.setVisibility(8);
            ˊॱ();
        } else if (1 == this.ˎˎ.ˎ()) {
            if (this.ˋˋ == null) {
                this.ˋˋ = (PostSectionContentView) this.ॱᐝ.inflate();
            }
            this.ˋˋ.setSectionContentClickListener(this);
            this.ˋˋ.setData(this.ˎˎ.ˊ(), this.ˎˎ.ˋॱ());
            this.ʻॱ.setVisibility(8);
            this.ॱᐝ.setVisibility(0);
            ʻ();
        }
    }

    protected void ʻ() {
        LayoutParams layoutParams = (LayoutParams) this.ˋˋ.getLayoutParams();
        if (this.ॱˎ.ॱˍ()) {
            layoutParams.topMargin = 0;
        } else {
            layoutParams.topMargin = this.ʼॱ.getResources().getDimensionPixelOffset(e.ʻ);
        }
        this.ˋˋ.setLayoutParams(layoutParams);
    }

    public void ʽ() {
        Section ˊ;
        if (this.ˎˎ != null) {
            ˊ = this.ˎˎ.ˊ();
        } else {
            ˊ = null;
        }
        if (ˊ != null) {
            cil.ˋ(this.ʼॱ, new a().ˊ(ˊ.ॱॱ()).ˋ());
            fjb ˎ = fho.ˏ().ˋ("Section").ˎ("section_detail_activity");
            ((ISectionDetailActivityProtocol) ˎ.ˊ()).setUri(ˊ.ॱॱ());
            fiu.ˊ().ˏ(this.ʼॱ, ˎ);
        }
    }

    public void ॱॱ() {
        super.ॱ(false);
    }

    protected void ॱ(Post post) {
        if (this.ˎˎ != null) {
            if (this.ˎˎ.ˎ() == 0) {
                ˋˋ();
                return;
            } else if (this.ˎˎ.ˎ() == 1) {
                ˎˎ();
                return;
            }
        }
        this.ᐝ.setText("");
        this.ˌ.setVisibility(8);
    }

    private void ˎˎ() {
        User ᐝ = this.ˎˎ.ᐝ();
        String str = null;
        if (ᐝ != null) {
            int i;
            String ˎ = ᐝ.ˎ();
            CharSequence ˋ = ᐝ.ˋ();
            if (cgy.ॱ(ˋ)) {
                ˋ = "";
            }
            this.ᐝ.setText(ˋ);
            if (ᐝ.ʻ()) {
                this.ˌ.setVisibility(0);
                this.ˌ.setImageResource(bsy.a.ʻ);
                i = 1;
            } else if (ᐝ.ᐝ()) {
                this.ˌ.setVisibility(0);
                this.ˌ.setImageResource(bsy.a.ॱॱ);
                i = 1;
            } else {
                this.ˌ.setVisibility(8);
                i = 0;
            }
            if (i != 0) {
                i = this.ʼॱ.getResources().getDimensionPixelOffset(e.ʽॱ) + this.ʼॱ.getResources().getDimensionPixelOffset(e.ॱˎ);
            } else {
                i = 0;
            }
            this.ᐝ.setMaxWidth((((((azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelOffset(e.ʿ) * 6)) - (this.ʼॱ.getResources().getDimensionPixelOffset(e.ʻॱ) * 2)) - bsp.ˏ(this.ˏॱ, this.ˏॱ.getText().toString())) - bsp.ˏ(this.ˋॱ, this.ˋॱ.getText().toString())) - (this.ʼॱ.getResources().getDimensionPixelOffset(e.ॱˎ) * 2)) - i);
            str = ˎ;
        } else {
            this.ᐝ.setText("");
            this.ˌ.setVisibility(8);
        }
        this.ˋᐝ.setVisibility(8);
        this.ˍ.setVisibility(0);
        bsx.ˋ(this.ʼॱ, this.ˍ, str);
    }

    private void ˋˋ() {
        CharSequence ˏ;
        String str = null;
        this.ˌ.setVisibility(8);
        this.ᐝ.setMaxWidth(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        Section ˊ = this.ˎˎ.ˊ();
        if (ˊ != null) {
            ˏ = ˊ.ˏ();
            str = ˊ.ॱ();
        } else {
            ˏ = null;
        }
        this.ˋᐝ.setVisibility(0);
        this.ˍ.setVisibility(8);
        eqx.ˏ(this.ˋᐝ, str, "app_default_icon");
        if (TextUtils.isEmpty(ˏ)) {
            this.ᐝ.setText("");
        } else {
            this.ᐝ.setText(ˏ);
        }
    }

    protected void ᐝ() {
        if (this.ˎˎ != null && this.ˎˎ.ʽ() != null) {
            ॱ(this.ˎˎ.ʽ());
        }
    }
}
